<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>增删改查</title>
</head>
<body>
    <div id="app">
        <div><button v-on:click="add()">添加</button></div>
        <table border="1">
            <tr>
                <td>id</td>
                <td>姓名</td>
                <td>性别</td>
                <td>年龄</td>
                <td>操作</td>
            </tr>
            <tr v-for="item in List">
                <td>{{item.id}}</td>
                <td>{{item.name}}</td>
                <td>{{item.sex}}</td>
                <td>{{item.age}}</td>
                <td>
                    <button>编辑</button>
                    <button>删除</button>
                </td>
            </tr>
        </table>
        <div v-show="showBox">
            <form action="">
                <table>
                    <tr>
                        <td>用户名：</td>
                        <td><input type="text"></td>
                    </tr>
                    <tr>
                        <td>性别：</td>
                        <td><input type="text"></td>
                    </tr>
                    <tr>
                        <td>年龄：</td>
                        <td><input type="text"></td>
                    </tr>
                    <tr>
                        <td></td>
                        <td>
                            <button>添加</button>
                            <button>更新</button>
                            <button>取消</button>
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
</body>
<!-- 开发环境版本，包含了有帮助的命令行警告 -->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
    const app = new Vue({
        el: '#app',
        data:{
            List:[
                {'id':1, 'name':'james001','sex':'男','age':29},
                {'id':2, 'name':'james002','sex':'男','age':29},
                {'id':3, 'name':'james003','sex':'男','age':29},
                {'id':4, 'name':'james004','sex':'男','age':29},
            ],
            showBox: false,
        },
        methods: {
            add: function(){
                this.showBox = true;
            }
        },
    });
</script>
</html>